(function(a){
    a.fn.extend({
        zebra:function(){
            $this=$(this).attr("id");
            if(arguments[0]){
                if(arguments[0].checks)this._checks=arguments[0].checks;
                if(this._checks)this._renderChecks($this)
                    }
                    $("#"+$this+" tr:gt(0) td").css({
                "font-size":"0.8em",
                "font-weight":"normal",
                "border":"1px solid transparent"
            });
            this._renderZebra($this)
            },
        _renderChecks:function($this){
            $("#"+$this+" tr").prepend('<td><input type="checkbox" name="sel'+$this+'" class="sel'+$this+'" onclick="zebraCheck(this);" value="0" /></td>');
            $($(".sel"+$this)[0]).val('selAll')
            },
        _renderZebra:function($this){
            $("#"+$this+" tr:even").addClass("ui-state-default");
            $("#"+$this+" tr:eq(0)").removeClass('ui-state-default').addClass("ui-widget-header");
            $("#"+$this+" tr:gt(0)").hover(function(){
                $(this).addClass('ui-state-hover')
                },function(){
                $(this).removeClass('ui-state-hover')
                });
            $("#"+$this).css({
                "border":"thin solid"
            })
            }
        });
this._checks=false
})(jQuery);
function zebraCheck($obj){
    if($($obj).val()!='selAll'){
        $padre=$($obj).parent().parent();
        if($($obj).attr("checked")==true)$($padre).addClass('ui-state-highlight');else $($padre).removeClass('ui-state-highlight');
        $tot=($("."+$($obj).attr("class")).length);
        $sel=($("."+$($obj).attr("class")+":checked").length);
        if(($sel+1)==$tot&&$($("."+$($obj).attr("class"))[0]).attr("checked")==false)$($("."+$($obj).attr("class"))[0]).attr("checked","checked");else $($("."+$($obj).attr("class"))[0]).attr("checked","")
            }else{
        if($($obj).attr("checked")==true)$.each($("."+$($obj).attr("class")+":gt(0)"),function(){
            $(this).attr("checked","checked");
            $padre=$(this).parent().parent();
            $($padre).addClass('ui-state-highlight')
            });else $.each($("."+$($obj).attr("class")+":gt(0)"),function(){
            $(this).attr("checked","");
            $padre=$(this).parent().parent();
            $($padre).removeClass('ui-state-highlight')
            })
        }
        }